package com.hackerrank.challenges.conway;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Solution {
	private static final char W = 'w', B = 'b';
	private static final int DEPTH = 16;
	// Head ends here
	private static char[][] nextState(char[][] b) {
		char[][] nb = new char[b.length][];
		for(int i = 0; i < b.length; i++) {
			nb[i] = new char[b[i].length];
			for(int j = 0; j < b[i].length; j++) {
				int cw = 0, cb = 0;
				if(i > 0) {
					if(j > 0) {
						if(b[i - 1][j - 1] == W)
							cw++;
						else if(b[i - 1][j - 1] == B)
							cb++;
					}
					if(b[i - 1][j] == W)
						cw++;
					else if(b[i - 1][j] == B)
						cb++;
					if(j < b[i].length - 1) {
						if(b[i - 1][j + 1] == W)
							cw++;
						else if(b[i - 1][j + 1] == B)
							cb++;
					}
				}
				if(j > 0) {
					if(b[i][j - 1] == W)
						cw++;
					else if(b[i][j - 1] == B)
						cb++;
				}
				if(j < b[i].length - 1) {
					if(b[i][j + 1] == W)
						cw++;
					else if(b[i][j + 1] == B)
						cb++;
				}
				if(i < b.length - 1) {
					if(j > 0) {
						if(b[i + 1][j - 1] == W)
							cw++;
						else if(b[i + 1][j - 1] == B)
							cb++;
					}
					if(b[i + 1][j] == W)
						cw++;
					else if(b[i + 1][j] == B)
						cb++;
					if(j < b[i].length - 1) {
						if(b[i + 1][j + 1] == W)
							cw++;
						else if(b[i + 1][j + 1] == B)
							cb++;
					}
				}
				// rule 1
				if(b[i][j] == '-' && cw + cb == 3)
					nb[i][j] = (cw > cb ? 'w' : 'b');
				// rule 2
				else if(b[i][j] != '-' && cw + cb >= 2 && cw + cb <= 3)
					nb[i][j] = b[i][j];
				// rule 3 and 4 are taken care
			}
		}
		return nb;
	}
	private static void nextMove(char p, char[][] b) {
		List<Integer> r = new ArrayList<Integer>(), c = new ArrayList<Integer>();
		int m = Integer.MIN_VALUE;
		for(int i = 0; i < b.length; i++) {
			for(int j = 0; j < b[i].length; j++) {
				if(b[i][j] != '-')
					continue;
				// calculate benefit of marking current cell
				// benefit = no. of (lessened opposite color + increased our color)
				int cw = 0, cb = 0;
				char[][] nb = b.clone();
				for(int d = 0; d < DEPTH; d++)
					nb = nextState(nb);
				for(int k = 0; k < nb.length; k++) {
					for(int l = 0; l < nb[i].length; l++) {
						if(nb[k][l] == W)
							cw++;
						else if(nb[k][l] == B)
							cb++;
					}
				}
				int pcw = 0, pcb = 0;
				nb = b.clone();
				nb[i][j] = p;
				for(int d = 0; d < DEPTH; d++)
					nb = nextState(nb);
				for(int k = 0; k < nb.length; k++) {
					for(int l = 0; l < nb[i].length; l++) {
						if(nb[k][l] == W)
							pcw++;
						else if(nb[k][l] == B)
							pcb++;
					}
				}
				int benefit = (cw - pcw) + (pcb - cb);
				if(p == W)
					benefit = -benefit;
				if(benefit > m) {
					m = benefit;
					r.clear();
					c.clear();
				}
				if(benefit >= m) {
					r.add(i);
					c.add(j);
				}
			}
		}
		int rand = (int)(Math.random() * r.size());
		System.out.println(r.get(rand) + " " + c.get(rand));
	}
	private static void nextMove(String player, String [] board){
		char[][] b = new char[board.length][];
		for(int i = 0; i < board.length; i++)
			b[i] = board[i].toCharArray();
		nextMove(player.charAt(0), b);
	}
	// Tail starts here
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String player = in.next();
		String board[] = new String[29];
		for(int i = 0; i < 29; i++)
			board[i] = in.next();
		nextMove(player,board);
	}
}
